<template>
	<el-main class="bg edit_wrap">
		<el-form ref="form" :model="form" status-icon label-width="120px" v-if="is_view()">

							<el-col v-if="user_group === '管理员' || $check_field('get','meeting_number') || $check_field('add','meeting_number') || $check_field('set','meeting_number')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="会议编号" prop="meeting_number">
												<el-input id="meeting_number" v-model="form['meeting_number']" placeholder="请输入会议编号"
							  v-if="user_group === '管理员' || (form['expert_seating_id'] && $check_field('set','meeting_number')) || (!form['expert_seating_id'] && $check_field('add','meeting_number'))" :disabled="disabledObj['meeting_number_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','meeting_number')">{{form['meeting_number']}}</div>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','conference_name') || $check_field('add','conference_name') || $check_field('set','conference_name')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="会议名称" prop="conference_name">
												<el-input id="conference_name" v-model="form['conference_name']" placeholder="请输入会议名称"
							  v-if="user_group === '管理员' || (form['expert_seating_id'] && $check_field('set','conference_name')) || (!form['expert_seating_id'] && $check_field('add','conference_name'))" :disabled="disabledObj['conference_name_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','conference_name')">{{form['conference_name']}}</div>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','meeting_type') || $check_field('add','meeting_type') || $check_field('set','meeting_type')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="会议类型" prop="meeting_type">
												<el-input id="meeting_type" v-model="form['meeting_type']" placeholder="请输入会议类型"
							  v-if="user_group === '管理员' || (form['expert_seating_id'] && $check_field('set','meeting_type')) || (!form['expert_seating_id'] && $check_field('add','meeting_type'))" :disabled="disabledObj['meeting_type_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','meeting_type')">{{form['meeting_type']}}</div>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','meeting_time') || $check_field('add','meeting_time') || $check_field('set','meeting_time')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="会议时间" prop="meeting_time">
												<el-input id="meeting_time" v-model="form['meeting_time']" placeholder="请输入会议时间"
							  v-if="user_group === '管理员' || (form['expert_seating_id'] && $check_field('set','meeting_time')) || (!form['expert_seating_id'] && $check_field('add','meeting_time'))" :disabled="disabledObj['meeting_time_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','meeting_time')">{{form['meeting_time']}}</div>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','meeting_venue') || $check_field('add','meeting_venue') || $check_field('set','meeting_venue')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="会议地点" prop="meeting_venue">
												<el-input id="meeting_venue" v-model="form['meeting_venue']" placeholder="请输入会议地点"
							  v-if="user_group === '管理员' || (form['expert_seating_id'] && $check_field('set','meeting_venue')) || (!form['expert_seating_id'] && $check_field('add','meeting_venue'))" :disabled="disabledObj['meeting_venue_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','meeting_venue')">{{form['meeting_venue']}}</div>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','participating_experts') || $check_field('add','participating_experts') || $check_field('set','participating_experts')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="参会专家" prop="participating_experts">
													<el-select v-if="user_group === '管理员' || (form['expert_seating_id'] && $check_field('set','participating_experts')) || (!form['expert_seating_id'] && $check_field('add','participating_experts'))" id="participating_experts" v-model="form['participating_experts']" :disabled="disabledObj['participating_experts_isDisabled']">
							<el-option v-for="o in list_user_participating_experts" :key="o['username']" :label="o['nickname'] + '-' + o['username']"
									   :value="o['user_id']">
							</el-option>
						</el-select>
						<el-select v-else-if="$check_field('get','participating_experts')" id="participating_experts" v-model="form['participating_experts']" :disabled="true">
							<el-option v-for="o in list_user_participating_experts" :key="o['username']" :label="o['nickname'] + '-' + o['username']"
									   :value="o['user_id']">
							</el-option>
						</el-select>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','expert_name') || $check_field('add','expert_name') || $check_field('set','expert_name')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="专家姓名" prop="expert_name">
												<el-input id="expert_name" v-model="form['expert_name']" placeholder="请输入专家姓名"
							  v-if="user_group === '管理员' || (form['expert_seating_id'] && $check_field('set','expert_name')) || (!form['expert_seating_id'] && $check_field('add','expert_name'))" :disabled="disabledObj['expert_name_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','expert_name')">{{form['expert_name']}}</div>
											</el-form-item>
			</el-col>
								<el-col v-if="user_group === '管理员' || $check_field('get','seat_number') || $check_field('add','seat_number') || $check_field('set','seat_number')" :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
				<el-form-item label="座位号码" prop="seat_number">
												<el-input id="seat_number" v-model="form['seat_number']" placeholder="请输入座位号码"
							  v-if="user_group === '管理员' || (form['expert_seating_id'] && $check_field('set','seat_number')) || (!form['expert_seating_id'] && $check_field('add','seat_number'))" :disabled="disabledObj['seat_number_isDisabled']"></el-input>
					<div v-else-if="$check_field('get','seat_number')">{{form['seat_number']}}</div>
											</el-form-item>
			</el-col>
					
	
	
	
	
	
	
			<el-col :xs="24" :sm="12" :lg="8" class="el_form_btn_warp">
				<el-form-item>
					<el-button type="primary" @click="submit()">提交</el-button>
					<el-button @click="cancel()">取消</el-button>
				</el-form-item>
			</el-col>

		</el-form>
	</el-main>
</template>

<script>
	import mixin from "@/mixins/page.js";

	export default {
		mixins: [mixin],
		data() {
			return {
				field: "expert_seating_id",
				url_add: "~/api/expert_seating/add?",
				url_set: "~/api/expert_seating/set?",
				url_get_obj: "~/api/expert_seating/get_obj?",
				url_upload: "~/api/expert_seating/upload?",

				query: {
					"expert_seating_id": 0,
				},

				form: {
								"meeting_number":  '', // 会议编号
										"conference_name":  '', // 会议名称
										"meeting_type":  '', // 会议类型
										"meeting_time":  '', // 会议时间
										"meeting_venue":  '', // 会议地点
										"participating_experts": 0, // 参会专家
										"expert_name":  '', // 专家姓名
										"seat_number":  '', // 座位号码
											"expert_seating_id": 0, // ID
						
				},
				disabledObj:{
								"meeting_number_isDisabled": false,
										"conference_name_isDisabled": false,
										"meeting_type_isDisabled": false,
										"meeting_time_isDisabled": false,
										"meeting_venue_isDisabled": false,
										"participating_experts_isDisabled": false,
										"expert_name_isDisabled": false,
										"seat_number_isDisabled": false,
										},

	
		
		
		
		
		
					// 用户列表
				list_user_participating_experts: [],
				
		
	
			}
		},
		methods: {


	
	
			
	
			
	
			
	
			
	
			
	
				/**
			 * 获取专家用户用户列表
			 */
			async get_list_user_participating_experts() {
                // if(this.user_group !== "管理员" && this.form["participating_experts"] === 0) {
                //     this.form["participating_experts"] = this.user.user_id;
                // }
                var json = await this.$get("~/api/user/get_list?user_group=专家用户");
                if(json.result && json.result.list){
                    this.list_user_participating_experts = json.result.list;
                }
                else if(json.error){
                    console.error(json.error);
                }
			},
					get_user_participating_experts(id){
				var obj = this.list_user_participating_experts.getObj({"user_id":id});
				var ret = "";
				if(obj){
					if(obj.nickname){
						ret = obj.nickname;}
					else{
						ret = obj.username;
					}
				}
				return ret;
			},
			
	
			
	
		
			/**
			 * 获取对象之前
			 * @param {Object} param
			 */
			get_obj_before(param) {
				var form = "";
																						// 获取缓存数据附加
				form = $.db.get("form");
							$.push(this.form ,form);
																																						
				if(this.form && form){
					Object.keys(this.form).forEach(key => {
						Object.keys(form).forEach(dbKey => {
							// if(dbKey === "charging_standard"){
							// 	this.form['charging_rules'] = form[dbKey];
							// 	this.disabledObj['charging_rules_isDisabled'] = true;
							// };
							if(key === dbKey){
								this.disabledObj[key+'_isDisabled'] = true;
							}
						})
					})
				}
																				$.db.del("form");
				return param;
			},

			/**
			 * 获取对象之后
			 * @param {Object} json
			 * @param {Object} func
			 */
			get_obj_after(json, func){


																								

			},

			/**
			 * 提交前验证事件
			 * @param {Object} 请求参数
			 * @return {String} 验证成功返回null, 失败返回错误提示
			 */
			submit_check(param) {
				let msg = null
																														return msg;
			},

			is_view(){
				var bl = this.user_group == "管理员";

				if(!bl){
					bl = this.$check_action('/expert_seating/table','add');
					console.log(bl ? "你有表格添加权限视作有添加权限" : "你没有表格添加权限");
				}
				if(!bl){
					bl = this.$check_action('/expert_seating/table','set');
					console.log(bl ? "你有表格添加权限视作有修改权限" : "你没有表格修改权限");
				}
				if(!bl){
					bl = this.$check_action('/expert_seating/view','add');
					console.log(bl ? "你有视图添加权限视作有添加权限" : "你没有视图添加权限");
				}
				if(!bl){
					bl = this.$check_action('/expert_seating/view','set');
					console.log(bl ? "你有视图修改权限视作有修改权限" : "你没有视图修改权限");
				}
				if(!bl){
					bl = this.$check_action('/expert_seating/view','get');
					console.log(bl ? "你有视图查询权限视作有查询权限" : "你没有视图查询权限");
				}

				console.log(bl ? "具有当前页面的查看权，请注意这不代表你有字段的查看权" : "无权查看当前页，请注意即便有字段查询权限没有页面查询权限也不行");

				return bl;
			},
			/**
			 * 上传文件
			 * @param {Object} param
			 */
			uploadimg(param) {
				this.uploadFile(param.file, "avatar");
			},

		},
		created() {
															this.get_list_user_participating_experts();
									},
	}
</script>

<style>
	.avatar-uploader .el-upload {
		border: 1px dashed #d9d9d9;
		border-radius: 6px;
		cursor: pointer;
		position: relative;
		overflow: hidden;
	}

	.avatar-uploader .el-upload:hover {
		border-color: #409EFF;
	}

	.avatar-uploader-icon {
		font-size: 28px;
		color: #8c939d;
		width: 178px;
		height: 178px;
		line-height: 178px;
		text-align: center;
	}

	.avatar {
		width: 178px;
		height: 178px;
		display: block;
	}




</style>
